<?php

class ReportController extends BaseController
{
    public function reasonAction() {
        Response::ajax(200, 'success', 
                self::model('report_reason')->getList());
    }
    
    public function addAction() {
        $data = [];
        $data['reason_id'] = intval(Request::getParams('reasonId'));
        $data['reason'] = strval(Request::getParams('reason'));
        $data['dynamic_id'] = intval(Request::getParams('dynamicId'));
        $data['uid'] = $this->user_info['uid'];
        $data['add_time'] = $data['update_time'] = date('Y-m-d H:i:s');
        try {
            if(self::model('report')->insert($data)) {
                Response::ajax(200, '举报成功');
            }
        } catch (Exception $exc) {
            echo $exc->getTraceAsString();
            Log::write('举报信息提交失败'.$exc->getTraceAsString(), 'WARN');
        }
        Response::ajax(SYSTEM_ERROR, '举报信息提交失败,请稍后再试');
    }
}